<template>
  <div>
    <account-card title="修改密码">
      <el-form label-width="100px" size="small">
        <el-form-item label="原密码">
          <el-input placeholder="原密码" v-model="loginForm.account" clearable></el-input>
        </el-form-item>

        <!-- 密码 -->
        <el-form-item label-width="100px" label="密码">
          <el-input placeholder="请输入新密码" v-model="loginForm.password" show-password></el-input>
        </el-form-item>
        <el-form-item label="确认密码">
          <el-input placeholder="请确认行密码" v-model="loginForm.checkPass" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="checkpwd" type="primary">提交</el-button>
          <el-button>重置</el-button>
        </el-form-item>
      </el-form>
    </account-card>
  </div>
</template>

<script>
import {checkoldpwd,editpwd} from '@/apis/users.js'
import AccountCard from "../../../components/accountcard/AccountCard.vue";
export default {
  components: {
    AccountCard,
  },
  data() {
    return {
      loginForm: {
        account: "",
        password: "",
        checkPass: "",
      },
    };
  },
  methods:{
    checkpwd(){
      checkoldpwd({oldPwd:this.loginForm.account,id:localStorage.getItem("id")}).then(res=>{
        console.log(res.data);
        editpwd({newPwd:this.loginForm.password,id:localStorage.getItem("id")}).then(res=>{
          console.log(res.data);
        }).catch(err=>{
          console.log(err);
        })
      }).catch(err=>{
        console.log(err);
      })
    }
  }
};
</script>

<style lang="less" scoped>
/deep/  .el-input__inner {
  width: 250px ;
}
</style>